﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Zzcore.Model;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;

namespace Zzcore.Controllers
{
    public class OrganizationinfoController : BaseController
    {
        private readonly ILogger<OrganizationinfoController> _logger;
        public OrganizationinfoController(ILogger<OrganizationinfoController> logger, IFreeSql fsql) : base(fsql)
        {
            this._logger = logger;
        }

        [HttpPost]
        public async Task<IDictionary<string, Object>> Update([FromForm] Organizationinfo organizationinfo) {
            int affrows = await _fsql.Update<Organizationinfo>().SetSource(organizationinfo).ExecuteAffrowsAsync();
            return RenderJson(data: affrows);
        }

        [HttpPost]
        public async Task<IDictionary<string, Object>> Show() {
            Organizationinfo department = await _fsql.Select<Organizationinfo>().Where(o => o.Id == 1).ToOneAsync();
            return RenderJson(data: department);
        }
    }
}
